#include<iostream>
using namespace std;

/*
    (1) array pointer;
    (2) pointer array;
*/
int main(void)
{
    int i;

    // 1-D array pointer
    int a1[10] = {1,2,3,4,5,6,7,8,9,10};
    int *pt1;
    pt1 = a1;  // pt1 = &array[0]
    for(i=0; i<10; i++)
    {
        cout<<*(pt1+i)<<' ';
    }
    cout<<endl;

    // 2-D array pointer
    int a2[3][4] = {11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34};
    int (*pt2)[4];  // array of int pointer
    pt2 = a2;
    cout<<(*pt2)<<endl;  // is adress to head of row
    for(i=0; i<4; i++)
    {
        cout<<(*pt2)[i]<<' ';
    }   
    cout<<endl;

    for(i=0; i<3; i++)
    {
        cout<<*(pt2+i)<<' ';
    }
    cout<<endl;

    // pointer array
    int *pt3[1];
    *pt3 = a1;  // p[0] pointe to a3[0], equal to pt3[0] = &a1[0]
    // pt3[0] = &a1[0];
    for(i=0; i<10; i++)
    {
        cout<<*(pt3[0]+i)<<' ';
    }
    cout<<endl;

    int *pt4[3];
    for(i=0; i<3; i++)
    {
        pt4[i] = a2[i];
        cout<<*pt4[i]<<endl;
    }

    // m row, n col ***
    int m=2, n=3;  // a2[2][3] = 34
    cout<<*(pt4[2]+n)<<endl;
    cout<<*(*(pt4+m)+n)<<endl;
    cout<<(*(pt4+m))[n]<<endl;
    cout<<pt4[m][n]<<endl;

    return 0;
}